package com.xzzz.backend.bsms.loadbalancer;//package com.xzzz.backend.upms.loadbalancer;
//
//import org.springframework.cloud.client.ServiceInstance;
//import org.springframework.cloud.loadbalancer.core.RandomLoadBalancer;
//import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
//import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
//import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//
///**
// * 轮询负载均衡策略, 不需要使用 {@link Configuration}
// * @author xzzz
// */
//public class CustomRandomLBConfig {
//
//    /**
//     * 修改LB策略为随机, 默认为轮询 {@link org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer}
//     *
//     * @param environment               环境
//     * @param loadBalancerClientFactory lbClient 工厂
//     * @return LB策略
//     */
//    @Bean
//    public ReactorLoadBalancer<ServiceInstance> randomLoadBalancer(Environment environment,
//                                                                   LoadBalancerClientFactory loadBalancerClientFactory) {
//        String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
//        return new RandomLoadBalancer(loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
//    }
//}
